﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WcfContrib.Errors;

namespace WcfContrib.Showcase.Service
{
    /// <summary>
    /// There are 3 built-in provided ways to add my error handler
    /// 1 - directly to the service host (check Program.cs)
    /// OR
    /// 2 - through service attribute (check Service.cs)
    /// OR
    /// 3 - through configuration (check App.config)
    /// </summary>
    class MyErrorHandler : IErrorContextHandler
    {
        #region IErrorContextHandler Members

        public void HandleError(Exception error, ActivationErrorContext errorContext)
        {
            Helpers.WriteLine(ConsoleColor.Red, "MyErrorHandler.HandleError:");
            Helpers.WriteLine(ConsoleColor.Red, "Error occured! ({0}) I can access the error context to get more information", error.GetType().FullName);
        }

        public WcfContrib.Extensions.MessageAccessMode RequiredMessageAccess
        {
            get { return WcfContrib.Extensions.MessageAccessMode.None; }
        }

        #endregion
    }
}
